package com.manager.util;

import java.util.Random;

public class CodeUtil {
	
	/*
	 * 注：包含边界值
	 */
	public static int getRandomInt(int min, int max){
		return min + (int)((Math.random() * (max - min + 1)));
	}
	
	/*
	 * 可包含的随机文字: [0-9a-zA-Z]
	 */
	public static String getRandomStr(int length){
		String codes = "a0klb1mnc2opd3qre4stf5uvg6wxh7yzi8j9";
		if(length > codes.length()){
			length = codes.length();
		}
		StringBuffer sb = new StringBuffer();
		Random r = new Random();
		for(int i = 0; i < length; i++){
			sb.append(codes.charAt(r.nextInt(codes.length())));
		}
		return sb.toString();
	}
	
	public static void main(String[] args) {
		int d = CodeUtil.getRandomInt(2, 6);
		System.out.println(d);
	}

}
